import { get, post, put, del } from '@/utils/http/request'
import { R, P } from '@/utils/http/type'

export * from './types/role'
import { AddRoleType, EditRoleType, RoleListType } from './types/role'

/**
 * 添加角色信息
 */
export const addRole = (data: AddRoleType) => {
  return post('/role/add', data)
}

/**
 * 获取角色列表
 */
export const getRoleList = (data: {
  roleName?: string
  size: number
  page: number
}) => {
  return get<P<RoleListType>>(`/role/list`, data)
}

//角色数据回填
export const getRoleInfo = (roleId: number) => {
  return get<R<EditRoleType>>(`/role/detail/${roleId}`)
}

//更新角色
export const editRole = (data: EditRoleType) => {
  return put('/role/update', data)
}
// 删除角色
export const deleteRole = (roleId: number) => {
  return del<R<EditRoleType>>(`/role/delete/${roleId}`)
}
